<?php

defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$uniacid = $_SESSION['uniacid'];
$mid = $_SESSION['uid'];
$basic=$this->plugin_setting('basic');
$return['advs']=$basic['image'];
$return['basic']=$basic;
if($_RQ['op']=='main'){
	/*******main*******/
	//商品详情
	$id = intval($_RQ['id']);
	if (empty($id)){
			exi( '活动不存在！','error');
		}
	$group=pdo_get('jy_aligroup_groups',array('id'=>$id,'uniacid'=>$_SESSION['uniacid'],'status'=>1));
	$goods=pdo_get('jy_weishop_goods',array('id'=>$group['goodsid'],'uniacid'=>$_SESSION['uniacid'],'status'=>1));
	if(empty($goods)) {
				
		exi( '你访问的商品不存在或已删除','error');
	}
	$goods['fightnum'] = pdo_fetchcolumn('select count(1) from ' . tablename('jy_aligroup_groups_order') . ' where goodid = :goodid and uniacid = :uniacid and is_team = 1 and status > 0 ', array(':goodid' => $goods['id'], ':uniacid' => $_SESSION['uniacid']));
	$goods['fightnum'] = $group['teamnum'] + $goods['fightnum'];
	if($group['agio']!=0){
		$goods['groupsprice'] = $group['agio']*$goods['price']/100;
	}else{
		$goods['groupsprice'] =$goods['price'];
	}
	//商品多图
	$goods['images']=json_decode($goods['images'],true);
	
	
	
	/*if ($type == 'single'){
		if (empty($goods['single'])) 
		{
			exi( '商品不允许单购，请重新选择！','error');
		}
	}
	if (empty($goods['stock'])) 
	{		
		exi( '商品库存为0，暂时无法购买，请浏览其他商品！','error');
		}
	}
	 
	//print_r($groups_count.'hhhh');exit; 
	*/

	$return['goods']=$goods;
	$return['group']=$group;
	exi($return);
}